package servlet;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by webrx on 2017-09-12.
 */
@WebServlet("/echarts")
public class Echarts extends HttpServlet{

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        PrintWriter out = resp.getWriter();
        String[] categories = {"衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"};
        Integer[] values = {5, 20, 56, 10, 10, 20};
        Map<String, Object> m = new HashMap<String, Object>();
        m.put("categories", categories);
        m.put("values", values);

        out.print(JSONObject.toJSONString(m));
    }
}
